extends MoveStateResource


class_name RedirectStateResource
"""
重定向
"""


## 转向的角度值,绝对角度以Vector.UP为起始量
@export_range(-180, 180, 1, "degrees") var angle: int = 0
## 是否是绝对角度(出生时的方向/当前方向)
@export var is_absolute_angle: bool = false
## 偏移位置
@export var location: Vector2 = Vector2.ZERO
## 是否是绝对位置(出生时的位置/当前位置)
@export var is_absolute_location: bool = false


func update(ctrl: MoveController, data: Dictionary, delta: float, duration: float) -> bool:
    var move: MoveComponent = ctrl.move_component
    move.direction = (ctrl.start_direction if is_absolute_angle else move.direction).rotated(deg_to_rad(angle))
    move.wrapper.position = (ctrl.start_position if is_absolute_location else move.wrapper.position) + location
    return true
